import java.io.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GodK
 * Date: 2024-08-03
 * Time: 18:57
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入源文件的路径: ");
        String srcPath = scanner.next();
        File srcFile = new File(srcPath);
        if (!srcFile.isFile()) {
            System.out.println("源文件路径有误!");
            return;
        }
        System.out.println("请输入目标文件的路径: ");
        String destPath = scanner.next();
        File destFile = new File(destPath);
        if(!destFile.getParentFile().isDirectory()){
            System.out.println("目标文件的路径有误!");
            return;
        }
        try (InputStream inputStream = new FileInputStream(srcPath)){
            OutputStream outputStream = new FileOutputStream(destFile);
            while(true){
                byte[] buffer = new byte[1024];
                int n = inputStream.read(buffer);
                System.out.println("n = " + n);
                if (n == -1) {
                    break;
                }
                outputStream.write(buffer, 0, n);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
